package com.dcbeida.model;

import com.dcbeida.MyApplication;
import com.dcbeida.utils.GenApiHashUrl;
import com.dcbeida.utils.JsonGet;

import dc.medicine.com.okhttplib.OkHttpUtils;
import dc.medicine.com.okhttplib.callback.AbsCallback;

/**
 * Created by hp on 2016/7/27.
 */
public class StoreModel {

    private static StoreModel mInventoryModel;

    private StoreModel() {

    }

    public static StoreModel newInstance() {
        if (mInventoryModel == null) {
            return new StoreModel();
        } else {
            return mInventoryModel;
        }
    }


    /**
     * 新增入库药品监管码
     *
     * @param drugcode
     * @param mAbsCallback
     */
    public void addstockindrugcodes(String drugcode, AbsCallback mAbsCallback) {
        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service", "addstockindrugcodes")
                .paramsApp("params", new JsonGet().putopt("drugcodes", drugcode).putopt("uid", MyApplication.user.getUid()).tostring()).execute(mAbsCallback);
    }


    /**
     * 11.	药店药品入库-新增入库记录
     * @param from			    来货单位
     * @param fromID			来货单位ID
     * @param invoiceMoney		金额
     * @param deliverImgUrl	送货单（拍照）
     * @param drugcodes 批量监管码codes（逗号连接）
     * @param addstocktime 入库时间
     * @param deliverytime 单据时间
     * @param quantity  入库总数量
     * @param mAbsCallback
     */
    public void addstockinlog(String from,int fromID,String invoiceMoney,String deliverImgUrl,
                              String drugcodes, String addstocktime, String deliverytime, int quantity, AbsCallback mAbsCallback) {
        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service", "addstockinlog")
                .paramsApp("params", new JsonGet()
                        .putopt("drugcodes", drugcodes)
                        .putopt("addstocktime", addstocktime)
                        .putopt("deliverytime", deliverytime)
                        .putopt("from", from)
                        .putopt("fromid", fromID)
                        .putopt("invoicemoney", invoiceMoney)
                        .putopt("deliverimgurl", deliverImgUrl)
                        .putopt("quantity", quantity)
                        .putopt("uid", MyApplication.user.getUid()).tostring()).execute(mAbsCallback);

    }

    public void getSourcelInfo(String keyword, AbsCallback mAbsCallback) {
        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service", "queryprovider")
                .paramsApp("params", new JsonGet().putopt("uid", MyApplication.user.getUid()).putopt("keyword", keyword).tostring()).execute(mAbsCallback);
    }


    public void getCancel() {
        OkHttpUtils.getInstance().cancelTag(this);
    }
}
